package zw_801_900.zw_806_写字符串需要的行数;

class Solution {

    public static void main(String[] args) {
        int[] widths = {10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10};
        String s = "abcdefghijklmnopqrstuvwxyz";
        int[] number = numberOfLines(widths, s);
        for (int i : number) {
            System.out.println(i);
        }

    }

    public static int[] numberOfLines(int[] widths, String s) {
        int i = 0, sum = 0, ans = 1;
        while (i < s.length()) {
            char ch = s.charAt(i);
            if ((sum + widths[ch - 'a']) <= 100) {
                sum += widths[ch - 'a'];
            } else {
                ans++;
                sum = widths[ch - 'a'];
            }
            i++;
        }
        return new int[]{ans, sum};
    }
}